<?php
function smarty_function_shiftcolour($params, &$smarty){
	$min = isset($params["min"]) ? $params["min"]+0 : 0;
	$value = $params["value"]-$min;
	$cross = $params["cross"]-$min;
	$limit = $params["limit"]-$min;
	
	if($value < $cross){
		$g = round(255 * (($cross - $value)/$cross));
		$r = 0;
	}else{
		$g = 0;
		$r = round(255 * ($value/$limit));
	}
	
	$b = 255 - ($r+$g);
	return "rgb({$r},{$g},{$b})";
}


/**
 *
 * c = 15
 * v = 5
 *
 * 15-5 = 10
 *
 * 10/15 =
 *
 */